import { Callout } from "nextra/components";
import CopyableCode from '@/components/CopyableCode'

# Troubleshooting Guide

This guide covers common issues developers and users might encounter when working with Ink, along with their solutions.

## Transaction Issues

### Nonce Out of Sync

If you encounter JSON-RPC internal errors or transactions getting stuck, your wallet's nonce may be out of sync with the network. Here's how to fix it:

#### For MetaMask Users:

1. Enable custom nonce in MetaMask:
   - Go to Settings > Advanced
   - Enable "Customize transaction nonce"

2. Find your next valid nonce using either method A or B:

   **Method A: Using Block Explorer**
   - Go to <CopyableCode code="https://explorer.inkonchain.com/address/YOUR_ADDRESS" /> (replace YOUR_ADDRESS with your address)
   - Find your most recent transaction where you were the sender (FROM address)
   - Click the transaction and then "View details"
   - Find the nonce value and add 1 to it - this is your next valid nonce

   **Method B: Using Command Line**
   ```bash
   curl -s -X POST -H "Content-Type: application/json" --data '{
     "jsonrpc":"2.0",
     "method":"eth_getTransactionCount",
     "params":["YOUR_ADDRESS", "latest"],
     "id":1
   }' https://rpc-gel.inkonchain.com | python3 -c "import sys, json; print(int(json.load(sys.stdin)['result'], 16))"
   ```
   Replace `YOUR_ADDRESS` with your wallet address. The number returned is your next valid nonce.

3. Send a recovery transaction:
   - Send a 0 ETH transaction to yourself
   - When prompted for the nonce, use the exact number you got from either method above
   - Increase the gas price slightly (tap + once in the Network Fee section)
   - The transaction should go through

4. Future transactions should now use the correct nonce

<Callout type="info">
  The recovery transaction typically costs around $0.05 in gas fees.
</Callout>

## Getting Help

If you're still experiencing issues:

1. Join our [Discord](http://discord.gg/inkonchain) for community support
2. Check the [Network Status Page](https://status.inkonchain.com/) for any ongoing incidents
3. Submit a detailed bug report on our [GitHub](https://github.com/inkonchain/docs/issues)